#encoding: utf-8
from turtle import *
import turtle

length = 4
angle = 90
speed(0)


def draw_path(path):
    for sym in path:
            if sym == "F":
                forward(length)
            elif sym == "-":
                left(angle)
            elif sym =="+":
                right(angle)

def apply_role(path):
    rule = "F-F+F+FF-F-F+F"
    return path.replace("F", rule) #重复模式

path = "F-F-F-F"
path= apply_role(path)
path= apply_role(path)
path= apply_role(path)

draw_path(path)
turtle.done()  #
